import request from '@/utils/request'
import type { CommonList, ILoginData, IUserInfo, UserItem, queryType } from '@/api/user/types'
import http from '@/utils/http'

enum API {
  LOGIN_URL = '/admin/acl/index/login', //'/user/login/',
  USERINFO_URL = '/admin/acl/index/info',
  LOGOUT_URL = '/admin/acl/index/logout'
}
// 用户登录，data:登录的表单对象，params:为登录客服端uuid标识image_code_id对象
export const reqLogin = (data: ILoginData) => {
  return request<any, Common<string>>({
    method: 'POST',
    url: API.LOGIN_URL,
    data
  })
}
// 获取用户信息
export const reqUserInfo = () => request.get<any, Common<IUserInfo>>(API.USERINFO_URL)
// 用户退出
export const reqLogout = () => request.post<any, any>(API.LOGOUT_URL)

// /////////////////////////////////////////////////////////////////
/** 获取用户信息
 * /admin/acl/index/info
 */
export const getAdminAclIndexInfoAPI = () => {
  return http<IUserInfo>({
    method: 'GET',
    url: API.USERINFO_URL
  })
}
/**
 * 用户登录
 * @param data 登录的表单对象，params:为登录客服端uuid标识image_code_id对象
 * 命名格式 请求方式请求路径API
 */
export const postAdminAclIndexLoginAPI = (data: ILoginData) => {
  return http<string>({
    method: 'POST',
    url: API.LOGIN_URL,
    data
  })
}

// /admin/user/{page}/{limit}
// 获取订单分页列表

export const getAdminUserAPI = (page: number = 1, limit: number = 10) => {
  return http<CommonList<UserItem>>({
    method: 'GET',
    url: `/admin/user/${page}/${limit}`
    // url: '/user/login'
  })
}
